<template>
  <el-table
    :data="volunteerList"
    height="335"
    style="width: 100%"
    :header-cell-style="{ 'border-bottom': 'none' }"
    :header-row-style="{ height: '60px' }"
    :cell-style="{ height: '60px', 'border-bottom': 'none' }"
    stripe
  >
    <el-table-column prop="index" label="志愿表" align="center">
      <template #default="spoce">
        <div :class="spoce.row.passed == 1 ? 'isPassed' : ''">
          {{ spoce.row.index }}
        </div>
      </template>
    </el-table-column>
    <el-table-column prop="title" label="名称" width="140" align="center">
      <template #default="spoce">
        <div class="df" :class="spoce.row.passed == 1 ? 'isPassed' : ''">
          <p>{{ spoce.row.title }}</p>
          <p class="tip">
            {{
              `${spoce.row.is_danzhao == 1 ? '(普高单招)' : spoce.row.is_danzhao == 2 ? '(中职单招)' : ''}`
            }}
          </p>
        </div>
      </template>
    </el-table-column>
    <el-table-column prop="sgname" label="批次" align="center">
      <template #default="spoce">
        <div>
          {{ spoce.row.batch }}
        </div>
      </template>
    </el-table-column>
    <el-table-column prop="sgname" label="科目" align="center">
      <template #default="spoce">
        <div :class="spoce.row.passed == 1 ? 'isPassed' : ''">
          {{ spoce.row.sgname }}
        </div>
      </template>
    </el-table-column>
   
    <el-table-column prop="section" label="位次" align="center">
      <template #default="spoce">
        <div :class="spoce.row.passed == 1 ? 'isPassed' : ''">
          {{ spoce.row.section }}
        </div>
      </template>
    </el-table-column>
    <el-table-column prop="score" label="分数" align="center">
      <template #default="spoce">
        <div :class="spoce.row.passed == 1 ? 'isPassed' : ''">
          {{ spoce.row.score }}
        </div>
      </template>
    </el-table-column>
    <el-table-column prop="type" label="成绩类型" align="center">
      <template #default="spoce">
        <div :class="spoce.row.passed == 1 ? 'isPassed' : ''">
          {{ spoce.row.isGKB == '0' ? '普通版' : '高考版' }}
        </div>
      </template>
    </el-table-column>
    <!-- <el-table-column prop="scheme" label="方案类型" width="100" align="center">
		<template #default="spoce">
		  <div>{{ spoce.row.isGKB == "0" ? "模拟填报" : "高考版" }}</div>
		</template>
    </el-table-column> -->
    <el-table-column prop="createFrom" label="创建人" align="center">
      <template #default="spoce">
        <div :class="spoce.row.passed == 1 ? 'isPassed' : ''">
          {{ spoce.row.createFrom == '0' ? '学生' : '专家' }}
        </div>
      </template>
    </el-table-column>
    <el-table-column
      prop="lastModificationTime"
      label="最后编辑时间"
      width="200"
    >
      <template #default="spoce">
        <div :class="spoce.row.passed == 1 ? 'isPassed' : ''">
          {{ spoce.row.lastModificationTime }}
        </div>
      </template>
    </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      :width="isShowOptionItem ? 250 : 60"
    >
      <template #default="spoce">
        <div v-if="spoce.row.status == 0 && spoce.row.passed == 0">
          <el-button
            link
            type="primary"
            size="small"
            @click="onClickOptionItem(spoce.$index, 0)"
            >查看</el-button
          >
          <el-button v-if="isShowOptionItem" link type="primary" size="small">
            <el-popconfirm
              confirm-button-text="删除"
              cancel-button-text="取消"
              icon-color="#626AEF"
              title="确认删除"
              @confirm="onClickOptionItem(spoce.$index, 3)"
            >
              <template #reference> 删除 </template>
            </el-popconfirm>
          </el-button>
        </div>
        <div v-else>
          <el-button
            link
            type="primary"
            size="small"
            v-if="spoce.row.passed == 0"
            @click="onClickOptionItem(spoce.$index, 0, spoce.row)"
            >查看</el-button
          >
          <el-button
             v-if="isShowOptionItem"
            link
            type="primary"
            size="small"
            :style="
              spoce.row.finalSchemeStatus == 1
                ? 'background-color: rgba(220, 220, 220, 0.2); border: 1px #626FFF solid;'
                : ''
            "

            @click="onClickOptionItem(spoce.$index, 1, spoce.row)"
            >最终方案</el-button
          >
          <!-- <el-button
            v-if="spoce.row.finalSchemeStatus == 1"
            link
            type="primary"
            size="small"
            @click="onClickOptionItem(spoce.$index, 6, spoce.row)"
            >取消最终方案
          </el-button> -->
          <el-button
            v-if="isShowOptionItem && spoce.row.passed == 0"
            link
            type="primary"
            size="small"
            :style="
              spoce.row.isStudentSee == 1
                ? 'background-color: rgba(220, 220, 220, 0.2); border: 1px #626FFF solid;'
                : ''
            "
            @click="onClickOptionItem(spoce.$index, 2, spoce.row)"
            >{{ spoce.row.isStudentSee == 1 ? '取消同步' : '同步至学生' }}
          </el-button>
          <el-button
            v-if="isShowOptionItem && spoce.row.passed == 0"
            link
            type="primary"
            size="small"
          >
            <el-popconfirm
              confirm-button-text="删除"
              cancel-button-text="取消"
              icon-color="#626AEF"
              title="确认删除"
              @confirm="onClickOptionItem(spoce.$index, 3, spoce.row)"
            >
              <template #reference> 删除 </template>
            </el-popconfirm>
          </el-button>
        </div>
      </template>
    </el-table-column>
  </el-table>
</template>
<script setup>

const emit = defineEmits(['onClickOptionItem']);

const { volunteerList, isShowOptionItem } = defineProps({
  volunteerList: {
    type: Array,
    default: [],
  },
  isShowOptionItem: {
    type: Boolean,
    default: true,
  },
});
/**
 * 点击志愿表操作选项
 * @param {Number} index 下标
 * @param {Number} type 操作类型 0-删除 1-最终方案 2-同步至学生 3-删除
 */
function onClickOptionItem(index, type, row) {
  emit('onClickOptionItem', index, type, row);
}
</script>
<style lang="scss" scoped>
.isPassed {
  color: #cdcdcd !important;
}
.df {
  display: flex;
  align-items: center;
}
.tip {
  color: #f00 !important;
  font-size: 10px;
  margin-left: 10px;
}
</style>
